home *** CD-ROM | disk | FTP | other *** search
- Path: tank.news.pipex.net!pipex!demon!le-vamp.demon.co.uk
- From: Kurt@le-vamp.demon.co.uk (Kurt Frary)
- Newsgroups: comp.lang.c++
- Subject: Is anyone good enough to solve this ?
- Date: Sun, 11 Feb 1996 21:37:03 GMT
- Message-ID: <824074487.16609@le-vamp.demon.co.uk>
- Reply-To: kurt@le-vamp.demon.co.uk
- NNTP-Posting-Host: le-vamp.demon.co.uk
- X-NNTP-Posting-Host: le-vamp.demon.co.uk
- X-Newsreader: Forte Agent .99c/32.126
-
- Here is a program that works, it writes a message on the screen,
- changes screen modes, plots three points and then writes another
- message and terminates.
-
- It is a 32 bit flat model program running under DOS/4GW.
-
- Question: Why will it not work if I take out the first cout and give a
- GPF ?
-
- #include <iostream.h>
- #include <iomanip.h>
-
- #include <stdio.h>
- #include <dos.h>
- #include <conio.h>
- #include <math.h>
-
- // don't do this for C stuff !!!!!
- //#pragma aux default parm [];
- void scrmode(char scrmode);
-
- // Lets make this neat code, Calculate the screens linear address!
- #define SCREEN_AREA 0xa000
- #define SCREEN_LIN_ADDR ((SCREEN_AREA) << 4)
- #define SCREEN_SIZE 320*200
-
- #define SCREEN_MODE 0x449
-
-
- // Here we Go !!!!!
- void main(void)
- {
- cout << "Program Now Running" << endl;
- // Wait for user to press a key:
- // while (!kbhit());
-
-
- // Store previous Screen mode
- // int oldmode=(int *)MK_FP(0x40,0x49); 16 bit method
- // Create oldmode of Char format equal to address of char pointer
- screen_mode.
- char oldmode=* (char *) SCREEN_MODE;
-
- // Set the bloody screen mode, kf coding style
- scrmode(0x13);
-
- // Set the screen pointer, like 16 bit but shift left 4 (16 bits for
- flat model)
- // char *screen = (char *) ((0xa000 <<4)); but as this is neat
- code!!!
- char *screen = (char *) SCREEN_LIN_ADDR;
-
-
- //Define Table to store points in
- #define nocoords 2 // 2=just x and y
- #define nopoints 3 // 3 sets of coords
-
- char xcoord=0;
- char ycoord=1;
- short int centrex,centrey;
- short int i;
-
- int offset; // 4 bytes for offset
- short int startx,starty ; // short int 0 to 65535 (2 Bytes)
-
- centrex=160;
- centrey=100;
-
- // Table of points, (short int 2 bytes (0 to 65535))
- short int point [nopoints][nocoords]={
- 140,80,
- 142,80,
- 144,80
- };
-
-
- // We now need an external loop to rotate the points using F
- // for (unsigned int angle=1; angle<=360; angle+=10)
- // {
-
- // This is the loop to plot the points using i
- char colour=11;
- for (i=0; i<nopoints; i++)
- {
-
- // Set starting coordinates for point
- startx=point[i][xcoord];
- starty=point[i][ycoord];
-
- // Calculate video memory offset of coordinates:
- offset=starty*320+startx;
-
- // Draw the point
- screen[offset]=colour;
-
- // Increase the colour
- colour++;
- }
-
-
- // Wait for user to press a key:
- while (!kbhit());
-
- scrmode(oldmode);
-
- cout << "Program Terminated Correctly" << endl;
- printf("kurt");
- }
-
-
-
- Kurt Frary
- Kurt@le-vamp.demon.co.uk
-
- Life is like a woman, you enjoy yourself, get fucked and then your fucked!
-
-